package com.iwhalecloud.citybrain.flow.platform.manager.domain.model;

import com.iwhalecloud.citybrain.flow.platform.manager.common.utils.RelativeDateFormatUtils;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.enums.MsgTypeEnum;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;

@Data
public class FlowMessageListVo {

    /**
     * 主键
     */
    private String id;

    /**
     * 通知类型
     */
    private String msgType;

    /**
     * 消息标题
     */
    private String msgTitle;

    /**
     * 接收人code
     */
    private String receiverCode;

    /**
     * 接收人名称
     */
    private String receiverName;

    /**
     * 发送人code
     */
    private String senderCode;

    /**
     * 发送人名称
     */
    private String senderName;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 消息内容
     */
    private String msgBoby;

    /**
     * 流程实例id
     */
    private String processInstanceId;

    /**
     * 任务id
     */
    private String taskId;

    /**
     * 0-未读，1-已读
     */
    private Integer status;

    /**
     * 流程名称(来源)
     */
    private String processName;

    private String msgTypeDescr;

    private String relativeTime;

    public FlowMessageListVo(FlowMessageVo entity) {
        BeanUtils.copyProperties(entity, this);
        this.msgTypeDescr = MsgTypeEnum.getDescrByCode(this.msgType);
        this.relativeTime = RelativeDateFormatUtils.format(this.createTime);
    }
}
